# -------
# Console
# -------

snippet cld "Console debug a variable" b
console.debug "$1", ${1:variable}
endsnippet

snippet clds "Console debug a string" b
console.debug '$0'
endsnippet

snippet clda "Console log arguments" b
console.debug arguments
endsnippet

# -----
# Ember
# -----

snippet p "Create a computed property"
(->
  $0
).property('${2:propertyName}')
endsnippet

snippet ps "Create a computed property"
((key, newValue) ->
  if arguments.length > 1
    # Setter
    ${1:@set('${2:key}', newValue)}

  $0
).property()
endsnippet

snippet observes "Create an observer"
observes${1:observerName}: (->
  $0
).observes('${2:observerName}')
endsnippet

snippet o "Create an observer"
observes${1:observerName}: (->
  $0
).observes('${2:observerName}')
endsnippet

snippet on "Create an 'on' function"
(->
  $0
).on('${2:didInsertElement}')
endsnippet

snippet oni "Create an 'on' init function"
(->
  $0
).on('init')
endsnippet

snippet g "Getter" i
get('${1:propertyName}')$0
endsnippet

snippet ga "Get this and assign" i
$1 = @get('${1:propertyName}')$0
endsnippet

snippet @_s "Super with arguments" i
@_super(${1:arguments...})$0
endsnippet

snippet ps "Setter for Computed Property" i
set('${1:propertyName}', ${2:value})$0
endsnippet

snippet sp "Setter Properties" i
setProperties(
  ${1:propertyName}: ${2:value},
  $0
)
endsnippet

snippet toggle "toggleProperty"
toggleProperty('${1:propertyName}')$0
endsnippet

snippet eld "Ember debug log"
Ember.Logger.debug ${1:value}$0
endsnippet

snippet elda "Ember debug log arguments"
Ember.Logger.debug arguments$0
endsnippet

snippet eli "Ember info log"
Ember.Logger.info ${1:value}$0
endsnippet

snippet ele "Ember error log"
Ember.Logger.error ${1:value}$0
endsnippet

snippet all "App logger log"
App.Logger.log ${1:value}$0
endsnippet

snippet ald "App debug log"
App.Logger.debug ${1:value}$0
endsnippet

snippet alda "App arguments log"
App.Logger.debug arguments$0
endsnippet

snippet ale "App error log"
App.Logger.error ${1:value}$0
endsnippet

snippet LOG "LOG.log"
LOG.error
  event: '${1:event}'
  ${2:secondary: ${3:event}}
  ${4:args: [${5:args}]}$0
endsnippet

snippet t "Translate" w
Ember.I18n.t('$0')
endsnippet

snippet rp "RSVP Promise" w
new Ember.RSVP.Promise (resolve, reject) =>
  $0
endsnippet

# Computed Property Aliases

snippet computed "Any computed macro"
Ember.computed.${1:name} '${2:property}'$0
endsnippet

snippet c "Any computed macro (c)"
Ember.computed.${1:name} '${2:property}'$0
endsnippet

snippet alias "Computed property alias"
Ember.computed.alias '${1:alias}'$0
endsnippet

snippet oneWay "oneWay computed macro"
Ember.computed.oneWay '${2:property}'$0
endsnippet

snippet readOnly "readOnly computed macro"
Ember.computed.readOnly '${2:property}'$0
endsnippet

snippet notEmpty "notEmpty computed macro"
Ember.computed.notEmpty '${2:property}'$0
endsnippet

# Run

snippet later "Ember.run.later macro"
Ember.run.later(=>
  , ${2:function}
, ${1:time})$0
endsnippet

snippet so "Ember.run.scheduleOnce"
Ember.run.scheduleOnce '${1:afterRender}', =>
  $0
endsnippet

# ------
# TomDoc
# ------

snippet #p "TomDoc Public"
# Public: ${1:Description}
#
# Returns ${2: nothing.}$0
endsnippet

snippet #i "TomDoc Internal"
# Internal: ${1:Description}
#
# Returns ${2: nothing.}$0
endsnippet
